package bb.lanxing.lib.devices.ble.ble.characteristic;

import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.content.Intent;
import bb.lanxing.lib.base.BaseApplication;
import bb.lanxing.lib.devices.ble.BLEAttributes;
import bb.lanxing.lib.devices.ble.BleCons;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleCharacteristic;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleService;
import java.util.UUID;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;

public final class SensorLocationCharacteristics extends BaseBleCharacteristic {
    private SensorLocation sensorLocation;

    public SensorLocationCharacteristics(BaseBleService bleService) {
        super(bleService);
        Intrinsics.checkNotNullParameter(bleService, "bleService");
    }

    public SensorLocation getSensorLocation() {
        return this.sensorLocation;
    }

    public void setSensorLocation(SensorLocation sensorLocation) {
        this.sensorLocation = sensorLocation;
    }

    @Override
    public UUID targetUUID() {
        UUID fromString = UUID.fromString(BLEAttributes.BLE_CHAR_SENSOR_LOCATION);
//        Intrinsics.checkNotNullExpressionValue(fromString, "fromString(BLEAttributes.BLE_CHAR_SENSOR_LOCATION)");
        return fromString;
    }

    @Override
    public void onValueUpdate(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
//        Intrinsics.checkNotNullParameter(gatt, "gatt");
//        Intrinsics.checkNotNullParameter(characteristic, "characteristic");
        this.sensorLocation = SensorLocation.Companion.from(characteristic.getIntValue(17, 0));
        BaseApplication context = getBleService().getDevice().getContext();
        Intent intent = new Intent(BleCons.ACTION_SENSOR_LOCATION);
        intent.putExtra(BleCons.EXTRA_SENSOR_LOCATION, this.sensorLocation);
        context.sendBroadcast(intent);
    }
}
